﻿
using System.Runtime.InteropServices;
//using eSpectrocolorimeterWrapper;

namespace Module_Debug.Hardware
{
    public class CMA01
    {
        bool bEnableColorMeter = true;
        long rtn = 0;
        int bCMA01_AutoConnect = 0;
        public double sx = 0.0;
        public double sy = 0.0;
        public double Lv = 0.0;
        bool bTrriger = true;


        public CMA01()
        {
        }

        public static class EllipsometerRefInterface
        {
            //[DllImport("eSpectrocolorimeterDll.dll",CallingConvention =CallingConvention.Cdecl, EntryPoint = "ESpectro_EnableColorMeter")]
            //public static extern bool ESpectro_EnableColorMeter();
            //[DllImport("eSpectrocolorimeterDll.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ESpectro_ColorMeter_GetxyY")]
            //public static extern int ESpectro_ColorMeter_GetxyY(ref double x, ref double y, ref double Y);

            //[DllImport("eSpectrocolorimeterDll.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ESpectro_ColorMeter_SetTrrigerMode")]
            //public static extern int ESpectro_ColorMeter_SetTrrigerMode(ref bool bTrriger);

            //[DllImport("eSpectrocolorimeterDll.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ESpectro_DisableColorMeter")]
            //public static extern void ESpectro_DisableColorMeter();

            [DllImport(@"Resources\CM-A01\eSpectrocolorimeterDll.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ESpectro_EnableColorMeter")]
            public static extern int ESpectro_EnableColorMeter();
            [DllImport(@"Resources\CM-A01\eSpectrocolorimeterDll.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ESpectro_ColorMeter_GetxyY")]
            public static extern int ESpectro_ColorMeter_GetxyY(ref double x, ref double y, ref double Y);

            [DllImport(@"Resources\CM-A01\eSpectrocolorimeterDll.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ESpectro_ColorMeter_SetTrrigerMode")]
            public static extern int ESpectro_ColorMeter_SetTrrigerMode(ref bool bTrriger);

            [DllImport(@"Resources\CM-A01\eSpectrocolorimeterDll.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "ESpectro_DisableColorMeter")]
            public static extern void ESpectro_DisableColorMeter();
        }

        public int CMA01_AutoConnect()
        {
            bCMA01_AutoConnect = 0;
            bCMA01_AutoConnect = EllipsometerRefInterface.ESpectro_EnableColorMeter();
            return bCMA01_AutoConnect;
        }
        public void CMA01_Disconnect()
        {
            EllipsometerRefInterface.ESpectro_DisableColorMeter();
        }
        public void CMA01_Measure_Lxy()
        {
            rtn = EllipsometerRefInterface.ESpectro_ColorMeter_GetxyY(ref sx, ref sy, ref Lv);
        }
        public void CMA01_SetTrrigerMode(bool mode)
        {
            //true 硬件触发 ； false 软件触发
            rtn = EllipsometerRefInterface.ESpectro_ColorMeter_SetTrrigerMode(ref bTrriger);
        }
    }


}
